/*
 * @Author: Jone XIn
 * @Date: 2022-01-10 21:48:40
 * @LastEditTime: 2022-01-10 23:08:23
 * @Description: Project model
 */
'use strict'

const { DataTypes, Model, Op } = require('sequelize');
class Project extends Model { }
const { db_config } = require('../config.json');
const dbInstance = require('../db/db');
const ProjectSeq = dbInstance.getSequelizeInstance(db_config);


Project.init(
    {
        uid: {
            autoIncrement: true,
            type: DataTypes.INTEGER,
            allowNull: false,
            primaryKey: true
        },
        sync_id: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        project_name: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        project_path: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        m_id: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        gen_time: {
            type: DataTypes.STRING,
            allowNull: true,
        },
    },
    {
        freezeTableName: true,
        sequelize: ProjectSeq,
        modelName: 'Project',
        timestamps: false
    }
)


Project.addProject = async (data) => {
    let res = await Project.create(data);
    return res;
}

module.exports = {
    Project
};